package com.lizonghui.googleplay.control;

import android.graphics.Color;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import com.lizonghui.googleplay.R;
import com.lizonghui.googleplay.base.BaseHolder;
import com.lizonghui.googleplay.bean.SubjectInfoBean;
import com.lizonghui.googleplay.config.Constants;
import com.lizonghui.googleplay.utils.UIUtils;

import butterknife.Bind;
import butterknife.ButterKnife;
import it.sephiroth.android.library.picasso.Picasso;

/**
 * Created by Administrator on 2016/6/23.
 * 创建subject的holder
 */
public class SubjectHolder extends BaseHolder<SubjectInfoBean> {


    @Bind(R.id.item_subject_iv_icon)
    ImageView mItemSubjectIvIcon;
    @Bind(R.id.item_subject_tv_title)
    TextView mItemSubjectTvTitle;

    //绑定数据(data)和视图（view）
    @Override
    public void refreshHolderView(SubjectInfoBean data) {
        //data
        //view
        mItemSubjectTvTitle.setText(data.des);//文本绑定
        mItemSubjectTvTitle.setTextColor(Color.BLACK);
        Picasso.with(UIUtils.getContext())
                .load(Constants.URLS.IMABASEURL + data.url)
                .into(mItemSubjectIvIcon);//图片请求绑定
    }

    //初始化视图，找孩子，变成成员变量
    @Override
    public View initHolderView() {
        View view = View.inflate(UIUtils.getContext(), R.layout.item_subject, null);

        ButterKnife.bind(this, view);
        return view;
    }
}
